package test_junit_shop.ManageConstruction;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.interactions.Action;
import org.openqa.selenium.interactions.Actions;

/**
 * Created by ZH on 2018/2/8.
 * 门店-施工开单
 */
public class AddConstructionOrder {
    private static AddConstructionOrder aco = new AddConstructionOrder();
    private WebDriver driver;
    public static AddConstructionOrder getInstance(){
        return aco;
    }
    public void setwDriver(WebDriver w){
        driver = w;
    }
    public WebDriver getwDriver(){
        return driver;
    }

    public void addCustomer() throws InterruptedException {
        Thread.sleep(2000);
        driver.switchTo().frame(driver.findElement(By.xpath("//*[@id=\"content-main\"]/iframe[2]")));
        driver.findElement(By.id("search")).sendKeys("1");
        Thread.sleep(1000);
        new Actions(driver).moveToElement(driver.findElement(By.xpath("//*[@id=\"vehicleOwnerMsg\"]/tr")));
        Thread.sleep(1000);
        driver.findElement(By.xpath("//*[@id=\"vehicleOwnerMsg\"]/tr")).click();
        Thread.sleep(1000);
    }

    public void addProject() throws InterruptedException {
        driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/h3[1]/button")).click();
        Thread.sleep(1000);
        driver.switchTo().frame(driver.findElement(By.xpath("/html/body/div[4]/div[2]/iframe")));
        driver.findElement(By.xpath("//*[@id=\"construction_category\"]/li[2]")).click();
        Thread.sleep(2000);
        driver.findElement(By.xpath("//*[@id=\"table\"]/tbody/tr[1]/td[1]/input")).click();
        driver.switchTo().defaultContent();
        driver.switchTo().frame(driver.findElement(By.xpath("//*[@id=\"content-main\"]/iframe[2]")));
        driver.findElement(By.xpath("/html/body/div[4]/div[3]/a[1]")).click();
        Thread.sleep(2000);
        driver.findElement(By.xpath("/html/body/div[2]/div/div/div/div/h3[2]/button")).click();
        Thread.sleep(1000);
        driver.switchTo().frame(driver.findElement(By.xpath("/html/body/div[4]/div[2]/iframe")));
        driver.findElement(By.xpath("//*[@id=\"table\"]/tbody/tr/td[1]/input")).click();
        driver.switchTo().defaultContent();
        driver.switchTo().frame(driver.findElement(By.xpath("//*[@id=\"content-main\"]/iframe[2]")));
        driver.findElement(By.xpath("/html/body/div[4]/div[3]/a[1]")).click();
        driver.findElement(By.xpath("//*[@id=\"select_product\"]/tr/td[2]/input")).sendKeys("1");
        Thread.sleep(1000);
        new Actions(driver).moveToElement(driver.findElement(By.xpath("//*[@id=\"select_product\"]/tr/td[2]/div/table/tbody/tr[2]")));
        Thread.sleep(1000);
        driver.findElement(By.xpath("//*[@id=\"select_product\"]/tr/td[2]/div/table/tbody/tr[2]")).click();
        Thread.sleep(1000);
        driver.findElement(By.id("settlement")).click();
        Thread.sleep(2000);
        driver.findElement(By.xpath("/html/body/div[4]/div[3]/a[1]")).click();
    }
}
